package com.crm.miaohe.mapper;

import com.crm.miaohe.model.TblCustomer;
import com.crm.miaohe.model.TblCustomerExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TblCustomerMapper {
    long countByExample(TblCustomerExample example);

    int deleteByExample(TblCustomerExample example);

    @Delete({
        "delete from tbl_customer",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into tbl_customer (name, organization_code, ",
        "organization_name, customer_type_code, ",
        "customer_type_name, customer_type_child_code, ",
        "customer_type_child_name, customer_num, ",
        "customer_id, biz_code, ",
        "biz_name, customer_kind_code, ",
        "customer_kind_name, principal, ",
        "phone_number, province, ",
        "city, district, address, ",
        "price_strategy, password, ",
        "deleted, approved, permiss, ",
        "wuliu_code, wuliu_name, ",
        "wuliu_order, order_qty, ",
        "freight, freight_fee, ",
        "create_time, create_user, ",
        "update_time, update_user, ",
        "version, locked, shoukuan_code, ",
        "shoukuan_name, company_code, ",
        "company_name, deposit_amount, ",
        "lock_amount, no_deposit_order, ",
        "over_deposit_order)",
        "values (#{name,jdbcType=VARCHAR}, #{organizationCode,jdbcType=VARCHAR}, ",
        "#{organizationName,jdbcType=VARCHAR}, #{customerTypeCode,jdbcType=VARCHAR}, ",
        "#{customerTypeName,jdbcType=VARCHAR}, #{customerTypeChildCode,jdbcType=VARCHAR}, ",
        "#{customerTypeChildName,jdbcType=VARCHAR}, #{customerNum,jdbcType=VARCHAR}, ",
        "#{customerId,jdbcType=INTEGER}, #{bizCode,jdbcType=VARCHAR}, ",
        "#{bizName,jdbcType=VARCHAR}, #{customerKindCode,jdbcType=VARCHAR}, ",
        "#{customerKindName,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, ",
        "#{phoneNumber,jdbcType=VARCHAR}, #{province,jdbcType=BIGINT}, ",
        "#{city,jdbcType=BIGINT}, #{district,jdbcType=BIGINT}, #{address,jdbcType=VARCHAR}, ",
        "#{priceStrategy,jdbcType=BIGINT}, #{password,jdbcType=VARCHAR}, ",
        "#{deleted,jdbcType=BIT}, #{approved,jdbcType=BIT}, #{permiss,jdbcType=INTEGER}, ",
        "#{wuliuCode,jdbcType=VARCHAR}, #{wuliuName,jdbcType=VARCHAR}, ",
        "#{wuliuOrder,jdbcType=INTEGER}, #{orderQty,jdbcType=INTEGER}, ",
        "#{freight,jdbcType=INTEGER}, #{freightFee,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{createUser,jdbcType=VARCHAR}, ",
        "#{updateTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=VARCHAR}, ",
        "#{version,jdbcType=BIGINT}, #{locked,jdbcType=BIT}, #{shoukuanCode,jdbcType=VARCHAR}, ",
        "#{shoukuanName,jdbcType=VARCHAR}, #{companyCode,jdbcType=VARCHAR}, ",
        "#{companyName,jdbcType=VARCHAR}, #{depositAmount,jdbcType=DOUBLE}, ",
        "#{lockAmount,jdbcType=DOUBLE}, #{noDepositOrder,jdbcType=VARCHAR}, ",
        "#{overDepositOrder,jdbcType=DOUBLE})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(TblCustomer record);

    int insertSelective(TblCustomer record);

    List<TblCustomer> selectByExample(TblCustomerExample example);

    @Select({
        "select",
        "id, name, organization_code, organization_name, customer_type_code, customer_type_name, ",
        "customer_type_child_code, customer_type_child_name, customer_num, customer_id, ",
        "biz_code, biz_name, customer_kind_code, customer_kind_name, principal, phone_number, ",
        "province, city, district, address, price_strategy, password, deleted, approved, ",
        "permiss, wuliu_code, wuliu_name, wuliu_order, order_qty, freight, freight_fee, ",
        "create_time, create_user, update_time, update_user, version, locked, shoukuan_code, ",
        "shoukuan_name, company_code, company_name, deposit_amount, lock_amount, no_deposit_order, ",
        "over_deposit_order",
        "from tbl_customer",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.crm.miaohe.mapper.TblCustomerMapper.BaseResultMap")
    TblCustomer selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") TblCustomer record, @Param("example") TblCustomerExample example);

    int updateByExample(@Param("record") TblCustomer record, @Param("example") TblCustomerExample example);

    int updateByPrimaryKeySelective(TblCustomer record);

    @Update({
        "update tbl_customer",
        "set name = #{name,jdbcType=VARCHAR},",
          "organization_code = #{organizationCode,jdbcType=VARCHAR},",
          "organization_name = #{organizationName,jdbcType=VARCHAR},",
          "customer_type_code = #{customerTypeCode,jdbcType=VARCHAR},",
          "customer_type_name = #{customerTypeName,jdbcType=VARCHAR},",
          "customer_type_child_code = #{customerTypeChildCode,jdbcType=VARCHAR},",
          "customer_type_child_name = #{customerTypeChildName,jdbcType=VARCHAR},",
          "customer_num = #{customerNum,jdbcType=VARCHAR},",
          "customer_id = #{customerId,jdbcType=INTEGER},",
          "biz_code = #{bizCode,jdbcType=VARCHAR},",
          "biz_name = #{bizName,jdbcType=VARCHAR},",
          "customer_kind_code = #{customerKindCode,jdbcType=VARCHAR},",
          "customer_kind_name = #{customerKindName,jdbcType=VARCHAR},",
          "principal = #{principal,jdbcType=VARCHAR},",
          "phone_number = #{phoneNumber,jdbcType=VARCHAR},",
          "province = #{province,jdbcType=BIGINT},",
          "city = #{city,jdbcType=BIGINT},",
          "district = #{district,jdbcType=BIGINT},",
          "address = #{address,jdbcType=VARCHAR},",
          "price_strategy = #{priceStrategy,jdbcType=BIGINT},",
          "password = #{password,jdbcType=VARCHAR},",
          "deleted = #{deleted,jdbcType=BIT},",
          "approved = #{approved,jdbcType=BIT},",
          "permiss = #{permiss,jdbcType=INTEGER},",
          "wuliu_code = #{wuliuCode,jdbcType=VARCHAR},",
          "wuliu_name = #{wuliuName,jdbcType=VARCHAR},",
          "wuliu_order = #{wuliuOrder,jdbcType=INTEGER},",
          "order_qty = #{orderQty,jdbcType=INTEGER},",
          "freight = #{freight,jdbcType=INTEGER},",
          "freight_fee = #{freightFee,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "create_user = #{createUser,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "update_user = #{updateUser,jdbcType=VARCHAR},",
          "version = #{version,jdbcType=BIGINT},",
          "locked = #{locked,jdbcType=BIT},",
          "shoukuan_code = #{shoukuanCode,jdbcType=VARCHAR},",
          "shoukuan_name = #{shoukuanName,jdbcType=VARCHAR},",
          "company_code = #{companyCode,jdbcType=VARCHAR},",
          "company_name = #{companyName,jdbcType=VARCHAR},",
          "deposit_amount = #{depositAmount,jdbcType=DOUBLE},",
          "lock_amount = #{lockAmount,jdbcType=DOUBLE},",
          "no_deposit_order = #{noDepositOrder,jdbcType=VARCHAR},",
          "over_deposit_order = #{overDepositOrder,jdbcType=DOUBLE}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TblCustomer record);
}